<template>
  <div v-loading="loading" class="m--15">
    <!-- <el-carousel class="home" trigger="click" height="350px" indicator-position="none" arrow="never" :autoplay="false">
      <el-carousel-item v-for="item in 1" :key="item">
        <div class="banner" :class="item">
          <div class="banner-title">
            <div class="banner-title-head1">JStore</div>
            <div class="banner-title-head2">以J博士投资管理系统为基础打造的应用市场平台，旨在为J博士系统用户更灵活的提供多 样化差异化的可复制的服务功能。</div>
          </div>
          <span class="banner-text" @click="toAppStore">前往JStore</span>
          <div class="myApp-img" />
        </div>
      </el-carousel-item>
    </el-carousel> -->
    <div class="pad90">
      <div class="app-header" style="margin-top:20px">
        <span><i class="el-icon-shopping-bag-1" /> {{ $t('已安装应用') }}</span>
      </div>
      <el-divider />
      <!-- <div class="area-header" style="margin-top:20px">
        <span class="area-header-title">{{ $t('已安装应用') }}</span>
      </div> -->
      <el-row :gutter="20">
        <el-col v-for="v in unInstallList" :key="v.id" :span="8">
          <div class="grid-content" @click="openApp(v)">
            <div class="grid-flex">
              <div class="logo">
                <img :src="v.appLogo" style="height: 100%;border-radius: 10px;">
              </div>
              <div class="re-info-flex">
                <div class="re-info-tit">
                  <div class="appName">
                    <span>{{ v.appName }}</span><i v-if="v.appAuthor">{{ v.appAuthor }}</i>
                  </div>
                  <p v-if="v.appNotes" class="dec">{{ filterHtmlTag(v.appNotes) }}</p>
                  <p v-else class="dec" />
                </div>
                <div class="operate install">
                  打开
                </div>
              </div>
            </div>
            <div class="updadate">{{ parseTime(v.createTime) }} 上架</div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import { getAppList } from '@/api/market/index'
import { config } from '@/utils'
import { getToken } from '@/utils/auth'
import router from '../../router'
import boutique from '@/assets/image/boutique.jpg'
export default {
    data() {
        return {
            boutique,
            dataList: [],
            installList: [],
            unInstallList: [],
            loading: false,
            appOpen: false,
            appInfo: {
              fileInfoList: []
            },
            params: {
              isUserInstall: 'Y'
            },
            infoLoading: false,
            imagesList: [
            ],
            token: getToken(),
            baseUrl: config.baseURL,
            boutiqueAppList: []
        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        filterHtmlTag(html) {
          var msg = html.replace(/<\/?[^>]*>/g, '')
          msg = msg.replace(/[|]*\n/, '')
          return msg
        },
        getList() {
          this.loading = true
          this.installList = []
          this.unInstallList = []
          getAppList(this.params).then(res => {
              if (res.code === 200 && res.rows.length > 0) {
                var rows = res.rows
                rows.forEach(v => {
                  if (v.state !== 0 && v.appPath) { // state: 0为卸载，1为安装
                    this.unInstallList.push(v)
                  }
                })
                this.loading = false
              }
          }).catch(() => {
            this.loading = true
          })
        },
        openApp(data) {
          const routeUrl = router.resolve({
            path: '/pathHandle',
            query: { path: data.menuPath }
          })
          window.open(routeUrl.href, '_blank')
        },
        toAppStore() {
          this.$router.push({ path: '/appStore' })
        }
    }
}
</script>
<style lang="scss" scoped>
.m--15{
  margin: -15px
}
.home .banner {
  background-color: #99a9bf;
  // background: url() center center no-repeat;
  background: url('~@/assets/image/JStore/myapp_background.png') center center no-repeat;
  // background: url() center center no-repeat;
  height: 100%;
  position: relative;
  // min-width: 1100px;
}
.myApp-img {
    background-image: url('~@/assets/image/JStore/myapp.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center center;
    width: 445px;
    height: 297px;
    position: absolute;
    top: 64px;
    right: 20%;
}
.pad90{
  padding: 0px 90px;
}
.recommend{
  padding: 56px 0px 40px;
  .b-tit{
    display: flex;
    align-items: center;
    margin-left: 8px;
    font-size: 20px;
    line-height: 32px;
    color: rgb(14, 17, 20);
    font-weight: 600;
    margin-bottom: 20px;
    i{
      color: #FFAB24;
      font-size: 25px;
    }
  }
  .re-main-flex{
    display: flex;
    column-gap: 20px;
    .re-main{
      flex: 1;
      min-width: 356px;
      height: 296px;
      background: rgb(255, 255, 255);
      box-sizing: border-box;
      border-radius: 3px;
      overflow: hidden;
      cursor: pointer;
      .re-banner{
        position: relative;
        width: 100%;
        height: 190px;
        // background: url(https://dfiles.tms.beisen.com/Portal/110006/597519f00d7341b4897c5c8be427557b.png) center center / cover no-repeat;
        background: center center / cover no-repeat;
      }

    }
  }
}
.tag{
  position: absolute;
  width: 110px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  left: -35px;
  top: 9px;
  padding: 5px 0 5px;
  transform: rotate(-45deg);
  background: #46CF84;
  color: #fff;
  font-size: 12px;
  zoom: 0.75;
}
.pay{
  background: #FE586A;
}
.re-info-flex{
  display: flex;
  padding: 24px;
  .re-info-tit{
    flex: 1;
    width: calc(100% - 100px);
  }
  .appName{
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    span{
      display: inline-block;
      font-weight: 600;
      vertical-align: middle;
      font-size: 18px;
      line-height: 26px;
      color: rgb(51, 56, 61);
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    i{
      font-style: normal;
      font-size: 11px;
      border-radius: 4px;
      border: 1px solid #EEF0F2;
      color: #6d6d6d;
      padding: 2px 3px;
      zoom: 0.9;
      margin-left: 8px;
      white-space: nowrap;
    }
  }
  .free{
    display: inline-block;
    height: 30px;
    padding: 0px 15px;
    line-height: 30px;
    font-size: 12px;
    text-align: center;
    color: rgb(255, 255, 255);
    border-radius: 15px;
    background: #1890ff;
    cursor: pointer;
    box-sizing: border-box;
  }
  .dec{
    font-size: 12px;
    line-height: 22px;
    color: rgb(131, 137, 143);
    margin: 0px;
    padding: 0px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.app-header{
  font-size: 16px;
  line-height: 28px;
  color: rgb(14, 17, 20);
  display: flex;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  justify-content: space-between;
  font-weight: 500;
  margin-bottom: 20px;
}
/deep/.app-dialog{
  background: #f6f7f9;
  padding: 20px;
  height: 80%;
  top: 10%!important;
  margin-top: 0!important;
  left: 0%!important;
  .el-dialog__header, .el-dialog__body{
    padding: 0!important;
    border: 0;
  }
  .el-dialog__body{
    height: 100%;
  }
  .app-details{
    height: 100%;
    display: flex;
    column-gap: 20px;
    .line{
      margin: 20px 0;
      border-top: 1px solid #F5F5F7;
    }
    .app-details-left{
      flex: 1;
      background: #fff;
      padding: 20px;
      border-radius: 4px;
      max-width: calc(100% - 320px);
      .scroll{
        height: calc(100% - 90px);
        overflow-y: auto;
        margin-right: -20px;
        padding-right: 20px;
      }
      .top{
        display: flex;
        align-items: center;
        column-gap: 7px;
        border-bottom: 2px dashed rgb(240, 242, 245);
        padding-bottom: 20px;
        margin-bottom: 25px;
        justify-content: space-between;
        i{
          cursor: pointer;
        }
        .iconfont{
          color: #FF5C66;
          font-size: 45px;
        }
        .name{
          flex: 1;
          max-width: calc(100% - 200px);
          .iconfont {
            font-size: 45px;
            color: #FE424B;
          }
          h2{
            display: inline-block;
            font-weight: 600;
            vertical-align: middle;
            font-size: 18px;
            line-height: 26px;
            color: #33383d;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            margin: 0;
            margin-bottom: 6px;
          }
          p{
            font-size: 12px;
            line-height: 22px;
            color: #83898f;
            margin: 0px;
            padding: 0px;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: block;
          }
        }
      }
      .app-pic{
      }
      h3{
        font-size: 15px;
        margin: 0;
        color: #000;
        margin: 20px 0 10px;
      }
      p{
        color: rgba(0, 0, 0, 0.75);
        font-size: 13px;
        margin: 0;
        line-height: 20px;
      }
    }
    .app-details-right{
      padding: 20px;
      border-radius: 4px;
      width: 300px;
      background: #fff;
      h2{
        font-size: 15px;
        margin: 0;
        color: #33383d;
      }
      p{
        color: #565e66;
        font-size: 13px;
        margin: 8px 0;
        line-height: 20px;
        i{
          color: #CFD2D5;
        }
      }
    }
  }
}

.grid-content{
    border-radius: 6px;
    margin-bottom: 20px;
    background: #fff;
    padding: 24px 20px 0px 24px;
    position: relative;
    height: 150px;
    overflow: hidden;
    .re-info-flex{
      padding: 0;
      flex: 1;
      max-width: calc(100% - 70px);
      display: flex;
      justify-content: space-between;
      .appName{
        margin-bottom: 6px
      }
      .re-info-tit{
        max-width: calc(100% - 70px);
      }
    }
    .grid-flex{
      display: flex;
      align-items: center;
      padding-bottom: 20px;
    }
    .updadate{
      padding: 12px 0px;
      font-size: 12px;
      line-height: 20px;
      color: rgb(131, 137, 143);
      border-top: 1px solid rgb(240, 242, 245);
    }
    .logo{
      width: 60px;
      height: 60px;
      border-radius: 10px;
      margin-right: 10px;
      i{
        font-size: 40px;
        color: #bebebe;
      }
    }

    .app-con{
        flex: 1;
        p{
            margin: 0;
        }
        .tit{
            font-size: 14px;
            font-weight: bold;
            margin-bottom: 10px;
        }
        .dec{
            font-size: 12px;
            color: #9EA4A6;
        }
    }
}
.area-header{
    margin-bottom: 20px;
}

.infoLogo{
  width: 60px;
  height: 60px;
  i{
    font-size: 40px;
    color: #bebebe;
  }
}
.operate{
  display: inline-block;
  height: 26px;
  padding: 0px 10px;
  line-height: 26px;
  font-size: 12px;
  text-align: center;
  border-radius: 13px;
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
  font-style: normal;
}
.install{
  color: rgb(21, 129, 238);
  background: rgba(21, 129, 239, 0.05);
}
.uninstall{
  color: rgb(254,81,99);
  background: rgba(254,81,99, 0.05);
}

.grid-content:hover, .re-main:hover{
  box-shadow: rgba(0,0,0,0.05) 0px 0px 8px 0px;
}

// .home {
//   padding: 0 50px;
// }

.banner-text {
  position: absolute;
    left: 23%;
    bottom: 14%;
    display: inline-block;
    height: 52px;
    width: 150px;
    line-height: 52px;
    font-size: 15px;
    text-align: center;
    color: rgb(255, 255, 255);
    border-radius: 26px;
    background: rgb(21, 129, 238);
    cursor: pointer;
    box-sizing: border-box;
}

.banner-title {
    background-size: 100%;
    width: 522px;
    height: 240px;
    position: absolute;
    top: 70px;
    left: 23%;
}

.banner-title-head1 {
    font-size: 36px;
    color: rgb(255, 255, 255);
    font-weight: 500;
    line-height: 50px;
    margin-bottom: 16px;
}

.banner-title-head2 {
    font-size: 18px;
    font-weight: 300;
    line-height: 25px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 66px;
}
</style>
